//
//  MineOrderUsedCell.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/9/5.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "MineOrderUsedCell.h"
@interface MineOrderUsedCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *completeLabel;
@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *numberLabel;
@property (nonatomic, strong) UILabel *currentPrice;
@property (nonatomic, strong) UILabel *originalPriceLabel;
@end
@implementation MineOrderUsedCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.backgroundColor = COLOR_BACKGROUND;
        UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, GWIDTH, 124 + 44)];
        bgView.backgroundColor = ColorWhite;
        [self addSubview:bgView];
        
        _titleLabel = [UILabel new];
        _titleLabel.text = @"爱儿美儿童摄影";
        _titleLabel.textColor = ColorFrom16(0x333333);
        _titleLabel.font = PFRFONT(14);
        [bgView addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(bgView).offset(12);
            make.left.equalTo(bgView).offset(10);
            make.width.greaterThanOrEqualTo(@114);
            make.height.equalTo(@20);
        }];
        
        _completeLabel = [UILabel new];
        _completeLabel.text = @"待使用";
        _completeLabel.textColor = ColorFrom16(0xF5CB37);
        _completeLabel.font = PFRFONT(14);
        [bgView addSubview:_completeLabel];
        [_completeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(bgView).offset(10);
            make.right.equalTo(bgView).offset(-12);
            make.width.equalTo(@56);
            make.height.equalTo(@20);
        }];
        
        UIView *line = [UIView new];
        line.backgroundColor = ColorFrom16(0xF0F0F0);
        [bgView addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(10.5);
            make.left.equalTo(bgView).offset(10);
            make.right.equalTo(bgView).offset(-10);
            make.height.equalTo(@1);
        }];
        
        _imgView = [UIImageView new];
        _imgView.backgroundColor = ColorCyan;
        _imgView.image = IMAGE(@"");
        [bgView addSubview:_imgView];
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(line.mas_bottom).offset(10);
            make.left.equalTo(bgView).offset(10);
            make.width.equalTo(@60);
            make.height.equalTo(@60);
        }];
        
        _nameLabel = [UILabel new];
        _nameLabel.text = @"爱儿美儿童女鞋秋季梦想儿童女鞋爱儿美儿童女鞋  橘色  13码";
        _nameLabel.textColor = ColorFrom16(0x323232);
        _nameLabel.font = PFRFONT(12);
        _nameLabel.numberOfLines = 2;
        [bgView addSubview:_nameLabel];
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(line.mas_bottom).offset(10);
            make.left.equalTo(_imgView.mas_right).offset(10);
            make.width.equalTo(@209);
            make.height.equalTo(@34);
        }];
        
        _numberLabel = [UILabel new];
        _numberLabel.text = @"数量  X1";
        _numberLabel.textColor = ColorFrom16(0x7F7E7D);
        _numberLabel.font = PFRFONT(12);
        [bgView addSubview:_numberLabel];
        [_numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLabel.mas_bottom).offset(9);
            make.left.equalTo(_imgView.mas_right).offset(10);
            make.width.greaterThanOrEqualTo(@80);
            make.height.equalTo(@17);
        }];
        
        _currentPrice = [UILabel new];
        _currentPrice.text = @"￥580.74";
        _currentPrice.textColor = ColorFrom16(0x202020);
        _currentPrice.font = PFRFONT(16);
        [bgView addSubview:_currentPrice];
        [_currentPrice mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLabel.mas_bottom).offset(4);
            make.right.equalTo(bgView).offset(-2);
            make.width.greaterThanOrEqualTo(@76);
            make.height.equalTo(@22);
        }];
        
        _originalPriceLabel = [UILabel new];
        _originalPriceLabel.text = @"￥610";
        _originalPriceLabel.textColor = ColorFrom16(0x999999);
        _originalPriceLabel.font = PFRFONT(14);
        _originalPriceLabel.attributedText = [GW_Tool setCutLine:_originalPriceLabel.text];
        [bgView addSubview:_originalPriceLabel];
        [_originalPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLabel.mas_bottom).offset(6);
            make.right.equalTo(_currentPrice.mas_left).offset(-10);
            make.width.greaterThanOrEqualTo(@37);
            make.height.equalTo(@20);
        }];
        
        UIView *aview = [UIView new];
        aview.backgroundColor = ColorFrom16(0xf0f0f0);
        [bgView addSubview:aview];
        [aview mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_imgView.mas_bottom).offset(11);
            make.left.and.right.equalTo(bgView);
            make.height.equalTo(@1);
        }];
        
        _gotoPaidBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_gotoPaidBtn setTitle:@"立即使用" forState:0];
        [_gotoPaidBtn setTitleColor:ColorFrom16(0xFF5B7A) forState:0];
        _gotoPaidBtn.titleLabel.font = PFRFONT(14);
        _gotoPaidBtn.layer.backgroundColor = ColorWhite.CGColor;
        _gotoPaidBtn.layer.cornerRadius = 2;
        _gotoPaidBtn.layer.borderWidth = 1;
        _gotoPaidBtn.layer.borderColor = ColorFrom16(0xFF5B7A).CGColor;
        [bgView addSubview:_gotoPaidBtn];
        [_gotoPaidBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(aview.mas_bottom).offset(6);
            make.right.equalTo(bgView).offset(-10);
            make.height.equalTo(@32);
            make.width.equalTo(@80);
        }];
        
        _refundBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_refundBtn setTitle:@"申请退款" forState:0];
        [_refundBtn setTitleColor:ColorFrom16(0x333333) forState:0];
        _refundBtn.titleLabel.font = PFRFONT(14);
        _refundBtn.titleLabel.font = PFRFONT(14);
        _refundBtn.layer.backgroundColor = ColorWhite.CGColor;
        _refundBtn.layer.cornerRadius = 2;
        _refundBtn.layer.borderWidth = 1;
        _refundBtn.layer.borderColor = ColorFrom16(0x7f7e7d).CGColor;
        [self addSubview:_refundBtn];
        [_refundBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_gotoPaidBtn);
            make.right.equalTo(_gotoPaidBtn.mas_left).offset(-10);
            make.width.equalTo(@80);
            make.height.equalTo(@32);
        }];
    }
    return self;
}

- (void)configViewWithModel:(AllOrderModel *)model
{
    _titleLabel.text = model.store_name;
    _completeLabel.text = model.status;
    [_imgView sd_setImageWithURL:[NSURL URLWithString:STRING(model.goods_img)] placeholderImage:nil];
    _nameLabel.text = model.goods_name;
    _numberLabel.text = [NSString stringWithFormat:@"数量 X%@", model.sum];
    _originalPriceLabel.text = [NSString stringWithFormat:@"￥%@", model.goods_price];
    _currentPrice.text = [NSString stringWithFormat:@"￥%@", model.sale_price];
    _originalPriceLabel.attributedText = [GW_Tool setCutLine:_originalPriceLabel.text];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
